package cn.edu.scau.cmi.wujiaxian.comprehensive.service;

import java.util.ArrayList;

import cn.edu.scau.cmi.wujiaxian.comprehensive.dao.TeacherDao;
import cn.edu.scau.cmi.wujiaxian.comprehensive.model.Teacher;

public class TeacherService {
	
	public static void main(String[] args) {
		TeacherService teacherService = new TeacherService();
		System.out.println(teacherService.selectTeachers());
	
	}
	
	/**
	 * 增加一个老师
	 * @param name
	 */
	public void addTeacher(String name) {
		TeacherDao teacherDao = new TeacherDao();
		Teacher teacher = new Teacher();
		teacher.setName(name);
		teacherDao.add(teacher);
	}
	
	/**
	 * 删除一个老师
	 * @param name
	 */
	public void deleteTeacher(String name) {
		TeacherDao teacherDao = new TeacherDao();
		teacherDao.delete("name", name);
	}
	
	/**
	 * 查找全部老师
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public ArrayList<Teacher> selectTeachers() {
		TeacherDao teacherDao = new TeacherDao();
		ArrayList<Teacher> teachers = (ArrayList<Teacher>) teacherDao.selectAll();
		return teachers;
	}
	
}
